package com.yztstudy.clients;

import com.yztstudy.clients.impl.CategoryHystrixImpl;
import com.yztstudy.entity.Category;
import com.yztstudy.param.PageParam;
import com.yztstudy.param.ProductHotParam;
import com.yztstudy.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 类别的远程调用接口
 */

@FeignClient(value = "category-service", fallback = CategoryHystrixImpl.class)
public interface CategoryFeignClient {


    /**
     * TODO 根据种类名查询主键
     * @param categoryName 种类名
     * @return
     */
    @GetMapping("/category/promo/{categoryName}")
    public R byName(@PathVariable String categoryName);


    /**
     * TODO 热门商品的ID查询
     * @param productHotParam 前端发过来的热门商品名称集合
     * @return
     */
    @PostMapping("/category/hots")
    public R hots(@RequestBody ProductHotParam productHotParam);

    /**
     * TODO 查询所有的类别
     * @return
     */
    @PostMapping("/category/list")
    public R list();


    /**
     * TODO 分页查询种类
     * @param pageParam 分页参数
     * @return
     */
    @GetMapping("/category/admin/list")
    public R listPage(@RequestBody PageParam pageParam);


    /**
     * TODO 新增分类
     * @param category 分类对象
     * @return
     */
    @PostMapping("/category/admin/save")
    public R saveCategory(@RequestBody Category category);


    /**
     * TODO 删除类别
     * @param categoryId 类别ID
     * @return
     */
    @PostMapping("/category/admin/remove")
    public R adminRemove(@RequestBody Integer categoryId);


    /**
     * TODO 更新类别
     * @param category 类别对象
     * @return
     */
    @PostMapping("/category/admin/update")
    public R adminUpdate(@RequestBody Category category);
}
